import Vue from "vue";
import VueRouter from "vue-router";
import Login from "@/views/Login.vue";
import Home from "@/views/Home.vue";
import ActivitiesOrder from "@/views/activitiesOrder/activitiesOrder.vue";
import CampusView from "@/views/campusView/campusView.vue";
import LostFound from "@/views/lostFound/lostFound.vue";
import MentorDemeanor from "@/views/mentorDemeanor/mentorDemeanor.vue";
import NotificationNews from "@/views/notificationNews/notificationNews.vue";
import WisdomQA from "@/views/wisdomQA/wisdomQA.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    component: Login,
  },
  {
    path: "/home",
    component: Home,
    redirect: "/wisdomQA",
    children: [
      {
        path: "/wisdomQA",
        component: WisdomQA,
      },
      {
        path: "/notificationNews",
        component: NotificationNews,
      },
      {
        path: "/activitiesOrder",
        component: ActivitiesOrder,
      },
      {
        path: "/lostFound",
        component: LostFound,
      },
      {
        path: "/campusExploration/campusView",
        component: CampusView,
      },
       {
        path: "/campusExploration/mentorDemeanor",
        component: MentorDemeanor,
      },
      
      
    ],
  },
];

const router = new VueRouter({
  routes,
});
//挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//   //to 将要访问的路径
//   //from 代表从哪个路径跳转而来
//   //next 是一个函数，表示放行
//   //next() 放行 next('/login') 强制跳转
//   if(to.path === '/login'){
//     return next();
//   } else {
//     //获取user
//     const user = window.sessionStorage.getItem('user');
//     if(!user){
//       return next('/login');
//     } else {
//       next();
//     }
//   }
// });

export default router;
